package com.xunji.xunji;

import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;

import com.huanxiao.base.base.BaseActivity;
import com.huanxiao.base.common.bean.EventMessage;
import com.huanxiao.base.common.ui.fragment.BannerFragment;
import com.xunji.xunji.db.dao.TraceDao;
import com.xunji.xunji.module.account.controller.UserAccount;
import com.xunji.xunji.module.account.ui.activity.ForgetPswdActivity;
import com.xunji.xunji.module.account.ui.activity.LoginActivity;
import com.xunji.xunji.module.account.ui.activity.RegisterActivity;
import com.xunji.xunji.module.account.ui.fragment.MenuFragment;
import com.xunji.xunji.module.account.ui.fragment.ScrollerFragment;
import com.xunji.xunji.module.trace.dao.Trace;

import java.util.Date;

public class MainActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // 透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    public void initBundleExtras(Bundle extras) {

    }

    @Override
    protected void initView() {

        BannerFragment f = BannerFragment.newInstance(0, 0);
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_banner, f).commit();


        MenuFragment fMenu = MenuFragment.newInstance();
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_menu, fMenu).commit();

       ScrollerFragment fScroller = ScrollerFragment.newInstance();
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_scroll, fScroller).commit();

        UserAccount.getInstance().refreshUserInfo(null);
        UserAccount.getInstance().refreshQiniuToken();

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Override
    public void onEventBusListener(EventMessage message) {
        super.onEventBusListener(message);

        if (message.getTag()==EVENT_LOGOUT){
            UserAccount.getInstance().logout();

        }
    }

    @Override
    protected boolean isBindEventBus() {
        return true;
    }


    @Override
    protected void onBackNavigationClick() {
        super.onBackNavigationClick();
    }
}
